

*************************************************************************
*Table A.3: Outcome missingness by treatment status: all households
*This table reports the rate at which various household outcomes measured in endline one (January - March) are not observed, by treatment status. We include all surveyed households and all households categorized as "ghosts"
*************************************************************************


use "${SurveyDataDir}/JH_ePOS_HH_DataforAnalysis.dta",clear

*******************************************************************************
* Keep if surveyed or classified as ghost
keep if ss_code == "SS01" | ghost_final == 1

preserve
tempfile HHdata_withghosts
save `HHdata_withghosts'
restore

*******************************************************************************
svyset [pw = pweight]


count if ghost_final == 1
scalar ghosts = r(N)
scalar obs = 3960   

*Get relative weights of AAY and PH rationcard holders by whether RC is in an urban area
sum pweight if rationcardtype == "AAY" & isurban == 0
scalar AAY_weight0 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 0
scalar PH_weight0 = r(sum)

sum pweight if rationcardtype == "AAY" & isurban == 1
scalar AAY_weight1 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 1
scalar PH_weight1 = r(sum)

preserve

* Missing answers
foreach var of varlist b16_wheat_weigh_mar17 b16_wheat_weigh_jan17 b16_wheat_weigh_feb17 b16_sugar_weigh_mar17 b16_sugar_weigh_jan17 b16_sugar_weigh_feb17 b16_salt_weigh_mar17 b16_salt_weigh_jan17 b16_salt_weigh_feb17 b16_rice_weigh_mar17 b16_rice_weigh_jan17 b16_rice_weigh_feb17 b16_kero_weigh_mar17 b16_kero_weigh_jan17 b16_kero_weigh_feb17 value_wheat_mar17 value_wheat_jan17 value_wheat_feb17 value_total_mar17 value_total_jan17 value_total_feb17 value_sugar_mar17 value_sugar_jan17 value_sugar_feb17 value_salt_mar17 value_salt_jan17 value_salt_feb17 value_rice_mar17 value_rice_jan17 value_rice_feb17 value_kero_mar17 value_kero_jan17 value_kero_feb17 {
	* the outcome variable for entire sample
	gen MI_`var' = (mi(`var'))     //count how many missing for each var
	replace `var'=MI_`var'
	local allMIvar "`allMIvar' "`var'" "
	

}


***These are the outcomes for the overall sample

unab outcomesAll: ghost_final b16_rice_weigh_jan17 b16_rice_weigh_feb17 b16_rice_weigh_mar17  b16_wheat_weigh_jan17 b16_wheat_weigh_feb17 b16_wheat_weigh_mar17 b16_sugar_weigh_jan17 b16_sugar_weigh_feb17 b16_sugar_weigh_mar17  b16_salt_weigh_jan17 b16_salt_weigh_feb17 b16_salt_weigh_mar17 b16_kero_weigh_jan17 b16_kero_weigh_feb17 b16_kero_weigh_mar17 value_rice_jan17 value_rice_feb17 value_rice_mar17 value_wheat_jan17 value_wheat_feb17 value_wheat_mar17 value_sugar_jan17 value_sugar_feb17 value_sugar_mar17 value_salt_jan17 value_salt_feb17 value_salt_mar17 value_kero_jan17 value_kero_feb17 value_kero_mar17 value_total_jan17 value_total_feb17 value_total_mar17 


label var ghost_final "HH classified as ghost"
label var b16_wheat_weigh_mar17 "Quantity wheat purchased in March" 
label var b16_wheat_weigh_jan17 "Quantity wheat purchased in January" 
label var b16_wheat_weigh_feb17 "Quantity wheat purchased in February" 
label var b16_sugar_weigh_mar17 "Quantity sugar purchased in March" 
label var b16_sugar_weigh_jan17 "Quantity sugar purchased in January"
label var b16_sugar_weigh_feb17 "Quantity sugar purchased in February"
label var b16_salt_weigh_mar17 "Quantity salt purchased in March"
label var b16_salt_weigh_jan17 "Quantity salt purchased in January"
label var b16_salt_weigh_feb17 "Quantity salt purchased in February"
label var b16_rice_weigh_mar17 "Quantity rice purchased in March"
label var b16_rice_weigh_jan17 "Quantity rice purchased in January"
label var b16_rice_weigh_feb17 "Quantity rice purchased in February"
label var b16_kero_weigh_mar17 "Quantity kerosene purchased in March"
label var b16_kero_weigh_jan17 "Quantity kerosene purchased in January"
label var b16_kero_weigh_feb17 "Quantity kerosene purchased in February"
label var value_wheat_mar17 "Value wheat purchased in March"
label var value_wheat_jan17 "Value wheat purchased in January"
label var value_wheat_feb17 "Value wheat purchased in February"
label var value_total_mar17 "Total value purchased in March"
label var value_total_jan17 "Total value purchased in January"
label var value_total_feb17 "Total value purchased in February"
label var value_sugar_mar17 "Value sugar purchased in March"
label var value_sugar_jan17 "Value sugar purchased in January"
label var value_sugar_feb17 "Value sugar purchased in February"
label var value_salt_mar17 "Value salt purchased in March"
label var value_salt_jan17 "Value salt purchased in January"
label var value_salt_feb17 "Value salt purchased in February"
label var value_rice_mar17 "Value rice purchased in March"
label var value_rice_jan17 "Value rice purchased in January"
label var value_rice_feb17 "Value rice purchased in February"
label var value_kero_mar17 "Value kerosene purchased in March"
label var value_kero_jan17 "Value kerosene purchased in January"
label var value_kero_feb17 "Value kerosene purchased in February"



* outputting the tables (using Attrition_table function)
loc stratification "strata"
loc clusteredSE "Yes"
eststo all: Attrition_table_svy "`outcomesAll'" "`stratification'" "`clusteredSE'"



#delimit ;
esttab all using "${OutputDir}/TableA_3.tex", replace
	cells("Mean1(fmt(%12.2g) label(Treatment)) Mean0(fmt(%12.2g) label(Control)) b(fmt(%12.2g) label(difference)) p(fmt(%12.2g) label(\(p\)-value))"
	) 
	nonumber alignment(r r r r) star(* .10 ** .05 *** .01) booktabs noobs mlabel("") label
	substitute("                    &            &            &            &            \\" "" "\sym{$*$}" "*" "\sym{**}" "$**$" "\sym{***}" "$***$");
	

#delimit cr


